package com.spring_mysql_redis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spring_mysql_redis.entity.Dynamic;
import com.spring_mysql_redis.entity.UserDynamic;
import org.apache.ibatis.annotations.Select;

public interface DynamicMapper extends BaseMapper<Dynamic> {

    IPage<Dynamic> selectDynamicList(Page<Dynamic> page);

    @Select("SELECT * from sp_dynamic a LEFT JOIN sp_user b on a.user_id=b.id")
    Page<UserDynamic> getUserDynamicList(Page<UserDynamic> iPage);

    @Select("SELECT a.id,a.user_id,a.title,a.content,a.image,a.video,a.create_time,a.likes,a.comments,b.uu_id,b.icon,b.nickname"
            +" from sp_dynamic a LEFT JOIN sp_user b on a.user_id=b.id where b.id = (#{userId})")
    Page<UserDynamic> getOneUserDynamicList(Page<UserDynamic> iPage,Integer userId);

}
